package problem78;

import java.util.ArrayList;
import java.util.List;

//78.子集
//https://leetcode.cn/problems/subsets/

class Solution {
    List<List<Integer>> ret = new ArrayList<>();
    List<Integer> list = new ArrayList<>();
    public List<List<Integer>> subsets(int[] nums) {
        dfs(nums, 0);
        return ret;
    }
    public void dfs(int[] nums, int u) {
        if(u == nums.length) {
            ret.add(new ArrayList(list));
            return;
        }

        //不选
        dfs(nums, u+1);

        //选
        list.add(nums[u]);
        dfs(nums, u+1);
        list.remove(list.size()-1);
    }
}